package com.example.zk2_lx.mvvm_base;

import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding;
import androidx.lifecycle.ViewModelProvider;

public abstract class BaseActivity<VDB extends ViewDataBinding,VM extends BaseViewModel> extends AppCompatActivity {
    protected VDB dataBinding;
    protected VM viewModel;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        dataBinding = DataBindingUtil.setContentView(this,bindLayout());
        viewModel = new ViewModelProvider(this).get(getViewModel());
        initView();
        initData();
    }
    protected abstract int bindLayout();
    protected abstract void initView();
    protected abstract void initData();
    protected abstract Class<VM> getViewModel();
}
